var app = new Vue({
    el: '#app',
    data: {
		assDetails:{
		},
		commentList:{},
    },
    created:function(){
    	var that = this;
		FastClick.attach(document.body);
	    that.getDetails(1);
	    that.getCommentList(1);
	    $("#asso-news li").last().css("border-bottom","none");
	},
    methods:{
		backTop:function(){
            window.history.go(-1);
        },
 			//获取详情
 			getDetails(id){
				var that =this;
 				if($.isMocked()){
					// Mock响应模板
					Mock.mock(/getDetails/, //getList：此路径与ajax的url对应，绑定劫持事件
					{
						'title':'@ctitle(5, 70)',
						'date':"@date('yyyy-MM-dd')",
						'textarea':	"@cparagraph(10,20)",
						'fromwhere':'@csentence(3,5)',
						'img':'@image()',
						'isLike':'@integer(0,1)',
						'is_collect':'@integer(0,1)',
						'list|0-5':[
							{
								'id|+1':'1',
								'title':'@ctitle(5, 70)',
								'date':"@date('yyyy-MM-dd')",
							}
						],
					});
				}
 				var id = id;
 				$.ajax({
 					type:"get",
 					url:"getDetails",
 					dataType: 'json',
 					data:{
 						id:id
 					},
 					success:function(res){
						that.assDetails = res;
 					},
 				})
 			},
 			//评论列表
 			getCommentList(){
 				var that =this;
 				if($.isMocked()){
					// Mock响应模板
					Mock.mock(/getCommentList/, //getList：此路径与ajax的url对应，绑定劫持事件
					{
						'list|0-5':[
							{
								'id|+1':'1',
								'word':'@ctitle(100, 300)',
								'userhead':"@image('100X100')",
								'time':'@datetime()',
								'username':'@cname(3,5)',
								'state':'@integer(0,2)'
							}
						],
						'total':'@integer(0,100)'
					});
				}
 				var id = id;
 				$.ajax({
 					type:"get",
 					url:"getCommentList",
 					dataType: 'json',
 					data:{
 						id:id
 					},
 					success:function(res){
						that.commentList = res;
 					},
 				})		
 			},
 			//点赞
 			chooseLike(){
 				$.toast("点赞成功");
 				var that = this;
 				that.assDetails.isLike = 1;
 				
 			},
 			//取消点赞
 			chanceLike(){
 				$.toast("取消点赞成功", "text");
 				var that = this;
 				that.assDetails.isLike = 0;
 			},
 			//收藏
			chooseCollect(){
 				$.toast("收藏成功");
 				var that = this;
 				that.assDetails.is_collect = 1;
 			},
 			//取消收藏
			chanceCollect(){
 				$.toast("取消收藏成功", "text");
 				var that = this;
 				that.assDetails.is_collect = 0;
 			},

	   }	
  })

